package observer;

import java.util.List;
import java.util.Vector;

/**
 * @author zhiqi.shao
 * @Date 2018/6/7 10:13
 */
public class PayStatusUpdateSubject implements Subject {

    private List<Observer>  observers=new Vector<>();

    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    /**
     * 通知观察者
     */
    @Override
    public void nofityObserver() {
        observers.forEach(observer -> observer.update());
    }

    public void updateStatus(int status){
        System.out.println("pay status is update:"+ status);
        this.nofityObserver();
    }
}
